package com.taobao.classloader;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;

import com.taobao.classloader.impl.ChildPriorLoadStrategy;

public class ClassLoaderScope {
	private String				scopeName;
	private boolean				defaultScope;
	private List<String>		jarPackagePath;
	private boolean				lazyLoadResources;
	private ClassLoadStrategy	loadStrategy	= new ChildPriorLoadStrategy();	;

	public URL[] getJarPackageURLs() throws MalformedURLException {
		if (jarPackagePath != null && jarPackagePath.size() > 0) {
			URL[] urls = new URL[jarPackagePath.size()];
			int i = 0;
			for (String s : jarPackagePath) {
				urls[i++] = new URL(s.trim());
			}
			return urls;
		}
		return null;
	}

	public boolean isLazyLoadResources() {
		return lazyLoadResources;
	}

	public void setLazyLoadResources(boolean lazyLoadResources) {
		this.lazyLoadResources = lazyLoadResources;
	}

	public String getScopeName() {
		return scopeName;
	}

	public void setScopeName(String scopeName) {
		this.scopeName = scopeName;
	}

	public boolean isDefaultScope() {
		return defaultScope;
	}

	public void setDefaultScope(boolean defaultScope) {
		this.defaultScope = defaultScope;
	}

	public List<String> getJarPackagePath() {
		return jarPackagePath;
	}

	public void setJarPackagePath(List<String> jarPackagePath) {
		this.jarPackagePath = jarPackagePath;
	}

	public ClassLoadStrategy getLoadStrategy() {
		return loadStrategy;
	}

	public void setLoadStrategy(ClassLoadStrategy loadStrategy) {
		this.loadStrategy = loadStrategy;
	}

	public static void main(String[] args) {
		System.out.println(System.getProperty("user.dir") );
//		System.out.println(new File("./").getAbsolutePath());
	}

	@Override
	public String toString() {
		return "ClassLoaderScope [scopeName=" + scopeName + ", loadStrategy=" + loadStrategy + "]";
	}
}
